<?php
// +----------------------------------------------------------------------
// | Fanwe 多语商城建站系统 (Build on ThinkPHP)
// +----------------------------------------------------------------------
// | Copyright (c) 2009 http://www.fanwe.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 云淡风轻(97139915@qq.com)
// +----------------------------------------------------------------------

// 前台菜单列表
class NavAction extends CommonAction{
	//定义站内的操作结构（可用于菜单配置）
	private $nav_conf = array(
		'article'=>array(
			'show',		//展示
		),
		'message'	=>array(
			'feedback',//意见反馈
		)
	);
	//增
	public function add()
	{
		$this->assign("module_list",$this->nav_conf);  //输出模块列表
		$new_sort = D(MODULE_NAME)-> max("sort") + 1;
		$this->assign('new_sort',$new_sort);
		$this->display();
	}

	
	//改
	public function edit()
	{
		$this->assign("module_list",$this->nav_conf);  //输出模块列表
		
		$name=$this->getActionName();
		$model = M ( $name );
		$id = $_REQUEST [$model->getPk ()];
		$vo = $model->getById ( $id );
		
		$action_list = $this->nav_conf;
		$action_list = $action_list[$vo['rec_module']];
		$res = array();
		foreach($action_list as $k=>$v)
		{
			$res[$k] = array('value'=>$v,'name'=>L("LANG_SHOW_".$v));
		}
		$this->assign("action_list",$res);
		
		$this->assign ( 'vo', $vo );
		$this->display ();
	}
	
	public function getActionList()
	{
		$rec_module = $_REQUEST['rec_module'];
		$action_list = $this->nav_conf;
		$action_list = $action_list[$rec_module];
		$res = array();
		foreach($action_list as $k=>$v)
		{
			$res[$k] = array('value'=>$v,'name'=>L("LANG_SHOW_".$v));
		}
		echo json_encode($res);
	}
	function updateNavTarget()
	{
		$id = intval($_REQUEST['id']);
		
		$target = intval($_REQUEST['target']);
		
		if(D("Nav")->where('id='.$id)->setField("target",$target))
			echo 1;
		else
			echo 0;
	}
}
?>